home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / RCS_56.ARJ / RCSKEYS.C < prev    next >
C/C++ Source or Header  |  1992-02-11  |  3KB  |  103 lines

  1. /*
  2.  *                     RCS keyword table and match operation
  3.  */
  4.  
  5. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  6.    Copyright 1990, 1991 by Paul Eggert
  7.    Distributed under license by the Free Software Foundation, Inc.
  8.  
  9. This file is part of RCS.
  10.  
  11. RCS is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2, or (at your option)
  14. any later version.
  15.  
  16. RCS is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with RCS; see the file COPYING.  If not, write to
  23. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. Report problems and direct all questions to:
  26.  
  27.     rcs-bugs@cs.purdue.edu
  28.  
  29. */
  30.  
  31.  
  32.  
  33. /* $Log: rcskeys.c,v $
  34.  * Revision 5.2  1991/08/19  03:13:55  eggert
  35.  * Say `T const' instead of `const T'; it's less confusing for pointer types.
  36.  * (This change was made in other source files too.)
  37.  *
  38.  * Revision 5.1  1991/04/21  11:58:25  eggert
  39.  * Don't put , just before } in initializer.
  40.  *
  41.  * Revision 5.0  1990/08/22  08:12:54  eggert
  42.  * Add -k.  Ansify and Posixate.
  43.  *
  44.  * Revision 4.3  89/05/01  15:13:02  narten
  45.  * changed copyright header to reflect current distribution rules
  46.  * 
  47.  * Revision 4.2  87/10/18  10:36:33  narten
  48.  * Updating version numbers. Changes relative to 1.1 actuallyt
  49.  * relative to 4.1
  50.  * 
  51.  * Revision 1.2  87/09/24  14:00:10  narten
  52.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  53.  * warnings)
  54.  * 
  55.  * Revision 4.1  83/05/04  10:06:53  wft
  56.  * Initial revision.
  57.  * 
  58.  */
  59.  
  60.  
  61. #include "rcsbase.h"
  62.  
  63. libId(keysId, "$Id: rcskeys.c,v 5.2 1991/08/19 03:13:55 eggert Exp $")
  64.  
  65.  
  66. char const *const Keyword[] = {
  67.     /* This must be in the same order as rcsbase.h's enum markers type. */
  68.     nil,
  69.     AUTHOR, DATE, HEADER, IDH,
  70.     LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE
  71. };
  72.  
  73.  
  74.  
  75.     enum markers
  76. trymatch(string)
  77.     char const *string;
  78. /* function: Checks whether string starts with a keyword followed
  79.  * by a KDELIM or a VDELIM.
  80.  * If successful, returns the appropriate marker, otherwise Nomatch.
  81.  */
  82. {
  83.         register int j;
  84.     register char const *p, *s;
  85.     for (j = sizeof(Keyword)/sizeof(*Keyword);  (--j);  ) {
  86.         /* try next keyword */
  87.         p = Keyword[j];
  88.         s = string;
  89.         while (*p++ == *s++) {
  90.             if (!*p)
  91.                 switch (*s) {
  92.                 case KDELIM:
  93.                 case VDELIM:
  94.                     return (enum markers)j;
  95.                 default:
  96.                     return Nomatch;
  97.                 }
  98.         }
  99.         }
  100.         return(Nomatch);
  101. }
  102.  
  103.